<template>
  <div>
    <nav-bar title="账号交易">
      <img 
        slot="right" 
        class="navbar_right" 
        src="../../../assets/img/home/ic_kefu_color.png" 
        alt=""
        @click="$router.push('/custom_center')">
    </nav-bar>
    <ul class="tab_box">
      <li 
        v-for="(item, index) in serverTitle" 
        :key="index"
        @click="itemClick(index)">{{item}}</li>
      <span class="line"></span>
    </ul>
    <div class="content_box">
      <transaction-buy v-if="currentIndex === 0"/>
      <transaction-sell v-else-if="currentIndex === 1"/>
      <transaction-mine v-else-if="currentIndex === 2"/>
    </div>
  </div>
</template>

<script>
import NavBar from '../../../components/common/navbar/NavBar.vue'
import TransactionBuy from './transaction/TransactionBuy.vue'
import TransactionSell from './transaction/TransactionSell.vue'
import TransactionMine from './transaction/TransactionMine.vue'
export default {
  components: {
    NavBar,
    TransactionBuy,
    TransactionSell,
    TransactionMine,
  },
  data() {
    return {
      serverTitle: ['买号', '卖号', '我的交易'],
      currentIndex: 0,
    }
  },
  methods: {
    itemClick(index) {
      if(index === 1) {
        this.$router.push('/transaction_sell')
      }else if(index === 2) {
        this.$router.push('/transaction_mine')
      }
    }
  },
}
</script>

<style lang="less" scoped>
.navbar_right {
  width: .586667rem;
  height: .586667rem;
}

.tab_box {
  position: fixed;
  top: 1.173333rem;
  left: 50%;
  transform: translateX(-50%);
  width: 10rem;
  height: 1.093333rem;
  line-height: 1.093333rem;
  font-size: .32rem;
  font-weight: 500;
  color: #666666;
  background: #fff;
  display: flex;
  text-align: center;
  li {
    flex: 1;
  }
  .list_active {
    font-size: .4rem;
    font-weight: bold;
    color: #222;
  }
  .line {
    position: absolute;
    bottom: 0;
    width: .44rem;
    height: .053333rem;
    background: #FF5543;
    transform: translateX(1.446667rem);
  }
}

.content_box {
  position: fixed;
  top: 2.266667rem;
  width: 10rem;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  overflow: scroll;
}

.content_box::-webkit-scrollbar {
  display: none;
}
</style>